Fix NegativeArraySizeException in PfbParser#412
Closed
OwenSanzas wants to merge 1 commit intoapache:trunkfrom
Closed
Fix NegativeArraySizeException in PfbParser#412OwenSanzas wants to merge 1 commit intoapache:trunkfrom
OwenSanzas wants to merge 1 commit intoapache:trunkfrom
Conversation
Add lower-bound check for negative size values from integer overflow in the PFB record size field. Extends the PDFBOX-6044 fix which only checked the upper bound.
asf-gitbox-commits
pushed a commit
that referenced
this pull request
Jan 30, 2026
…ng; closes #412 git-svn-id: https://svn.apache.org/repos/asf/pdfbox/branches/3.0@1931622 13f79535-47bb-0310-9956-ffa450edef68
Contributor
|
Thank you; for some reason asfgit didn't close but it has been committed to the trunk, 3.0 and 2.0. Please close the PR yourself. |
Author
|
@THausherr Thanks for the quick fix across all three branches! One small request — could you leave a brief acknowledgment of our team (Team FuzzingBrain, O2Lab, Texas A&M University) in this thread or send to zesheng@tamu.edu? This kind of upstream recognition helps with our research funding. Thank you! |
Contributor
|
Thank you Team FuzzingBrain, O2Lab, Texas A&M University! |
Author
|
Thanks a lot! You're the hero! |
asf-gitbox-commits
pushed a commit
that referenced
this pull request
Feb 2, 2026
…ng; closes #412 git-svn-id: https://svn.apache.org/repos/asf/pdfbox/branches/2.0@1931623 13f79535-47bb-0310-9956-ffa450edef68
asf-gitbox-commits
pushed a commit
that referenced
this pull request
Feb 2, 2026
…ng; closes #412 git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1931624 13f79535-47bb-0310-9956-ffa450edef68
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NegativeArraySizeException in PfbParser due to Integer Overflow
Summary
PfbParser in Apache PDFBox's fontbox component reads a 4-byte size field as a signed integer without validating for negative values. When processing a malformed PFB font, integer overflow causes a negative size value, leading to
NegativeArraySizeExceptionand application crash.Type: Integer Overflow (CWE-190)
Severity: Medium (CVSS ~5.5)
Impact: Denial of Service (application crash)
Affected Component:
fontbox/src/main/java/org/apache/fontbox/pfb/PfbParser.java:162Root Cause
Vulnerable Code (PfbParser.java:152-162)
When the 4th byte of the size field is >= 0x80, Java's signed integer arithmetic causes overflow to negative. The PDFBOX-6044 bounds check
size > pfb.lengthonly validates the upper bound — negative values pass through and crash at array allocation.PoC
Trigger file
A crafted
malicious_pfb.pdfwith an embedded Type1 font containing an 18-byte PFB payload with size field01 00 00 FFthat overflows to -16777215.How to generate crash.bin
Hex structure (18 bytes):
0x80— Start marker0x01— ASCII segment type01 00 00 FF— Size field (little-endian), overflows to -16777215How to generate malicious_pfb.pdf
Trigger Method 1: Official pdfbox-app CLI
Output:
Note:
NegativeArraySizeExceptionis aRuntimeException, not caught byPDType1Fontwhich only catchesIOExceptionandDamagedFontException.Trigger Method 2: Direct API